﻿Imports System.Data.OracleClient
Imports System.IO
Imports System.Collections.Generic
Imports System.Web.Security
Imports System.Data

Public Class BSCSCampaignSegment
    'Inherits System.Web.UI.Page
    Inherits [lib].BasePage

    Dim tariffListGeneral As DropDownList
    Dim kwBoxGeneral As TextBox
    Dim DataEngine As New BSCSCampaignDefinition


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.PageTitle = "Kampanya Segment Bilgileri"
        Session("_CampaignSegmentDefinition") = Nothing

        If (Not IsPostBack) Then
        End If

    End Sub

    Protected Sub ClearRow(ByVal rowId As Integer)
        If rowId = 0 Then 'SameAs
            ddlSameAsTariff.Items.Clear()
            ddlSameAsTariff.Items.Insert(0, New ListItem("Evet", "Yes"))
            ddlSameAsTariff.Items.Insert(1, New ListItem("Hayır", "No"))
            ddlSameAsTariff.SelectedIndex = 1
            sameAsBox01_a.Visible = False
            sameAsBox01_b.Visible = False
            sameAsBox01_c.Visible = False
            txtKeywordGeneral.Text = Nothing
            ddlTariffListGeneral.Items.Clear()
            lblErr01.Text = Nothing
        End If
        If rowId = 1 Then 'Date
            datepicker.Value = Nothing
        End If
        If rowId = 2 Then 'TariffType
            ddlTariffType.Items.Clear()
            ddlTariffType.Items.Insert(0, New ListItem("Seçiniz", "0"))
            ddlTariffType.Items.Insert(1, New ListItem("Bireysel", "Bireysel"))
            ddlTariffType.Items.Insert(2, New ListItem("Kurumsal", "Kurumsal"))
            ddlTariffType.SelectedIndex = 0
            sameAsBox02_a.Visible = False
            sameAsBox02_b.Visible = False
            sameAsBox02_c.Visible = False
            txtKeyword02.Text = Nothing
            ddlTariffList02.Items.Clear()
            lblErr02.Text = Nothing
        End If
        If rowId = 3 Then 'TariffLineType
            ddlTariffLineType.Items.Clear()
            sameAsBox03_a.Visible = False
            sameAsBox03_b.Visible = False
            sameAsBox03_c.Visible = False
            txtKeyword03.Text = Nothing
            ddlTariffList03.Items.Clear()
            lblErr03.Text = Nothing
        End If
        If rowId = 4 Then 'TariffDeviceSegment
            ddlTariffDeviceSegment.Items.Clear()
            sameAsBox04_a.Visible = False
            sameAsBox04_b.Visible = False
            sameAsBox04_c.Visible = False
            txtKeyword04.Text = Nothing
            ddlTariffList04.Items.Clear()
            lblErr04.Text = Nothing
        End If
        If rowId = 5 Then 'TariffSegment
            ddlTariffSegment.Items.Clear()
            sameAsBox05_a.Visible = False
            sameAsBox05_b.Visible = False
            sameAsBox05_c.Visible = False
            txtKeyword05.Text = Nothing
            ddlTariffList05.Items.Clear()
            lblErr05.Text = Nothing
        End If
        If rowId = 6 Then 'GPO
            ddlGPOSegment.Items.Clear()
            sameAsBox06_a.Visible = False
            sameAsBox06_b.Visible = False
            sameAsBox06_c.Visible = False
            txtKeyword06.Text = Nothing
            ddlTariffList06.Items.Clear()
            lblErr06.Text = Nothing
        End If
        If rowId = 8 Then 'JET
            ddlIsJetTariff.Items.Clear()
            sameAsBox08_a.Visible = False
            sameAsBox08_b.Visible = False
            sameAsBox08_c.Visible = False
            txtKeyword08.Text = Nothing
            ddlTariffList08.Items.Clear()
            lblErr08.Text = Nothing
        End If
        If rowId = 9 Then 'M2M
            ddlIsM2MTariff.Items.Clear()
            sameAsBox09_a.Visible = False
            sameAsBox09_b.Visible = False
            sameAsBox09_c.Visible = False
            txtKeyword09.Text = Nothing
            ddlTariffList09.Items.Clear()
            lblErr09.Text = Nothing
        End If
        If rowId = 10 Then 'CorpSMS
            ddlIsCorpSMSTariff.Items.Clear()
            sameAsBox10_a.Visible = False
            sameAsBox10_b.Visible = False
            sameAsBox10_c.Visible = False
            txtKeyword10.Text = Nothing
            ddlTariffList10.Items.Clear()
            lblErr10.Text = Nothing
        End If
        If rowId = 11 Then 'FPM
            ddlIsFPMTariff.Items.Clear()
            sameAsBox11_a.Visible = False
            sameAsBox11_b.Visible = False
            sameAsBox11_c.Visible = False
            txtKeyword11.Text = Nothing
            ddlTariffList11.Items.Clear()
            lblErr11.Text = Nothing
        End If
        If rowId = 12 Then 'POS
            ddlIsPOSTariff.Items.Clear()
            sameAsBox12_a.Visible = False
            sameAsBox12_b.Visible = False
            sameAsBox12_c.Visible = False
            txtKeyword12.Text = Nothing
            ddlTariffList12.Items.Clear()
            lblErr12.Text = Nothing
        End If
    End Sub

    Protected Sub SetVisibilityOfGroup(ByVal group As String, ByVal tf As Boolean)
        If group.Equals("all") Then
            tariffLineType.Visible = tf
            tariffDeviceSegment.Visible = tf
            tariffSegment.Visible = tf
            GPOSegment.Visible = tf
            isM2MTariff.Visible = tf
            isJetTariff.Visible = tf
            isCorpSMSTariff.Visible = tf
            isFPMTariff.Visible = tf
            isPOSTariff.Visible = tf
        ElseIf group.Equals("bses") Then
            SetVisibilityOfGroup("all", False)
            tariffLineType.Visible = tf
            tariffDeviceSegment.Visible = tf
            tariffSegment.Visible = tf
            GPOSegment.Visible = tf
        ElseIf group.Equals("bfct") Then
            SetVisibilityOfGroup("all", False)
            tariffLineType.Visible = tf
            tariffSegment.Visible = tf
            GPOSegment.Visible = tf
        ElseIf group.Equals("bdata") Then
            SetVisibilityOfGroup("all", False)
            isM2MTariff.Visible = tf
            isJetTariff.Visible = tf
            tariffLineType.Visible = tf
            tariffSegment.Visible = tf
            GPOSegment.Visible = tf
        ElseIf group.Equals("kses") Then
            SetVisibilityOfGroup("all", False)
            tariffLineType.Visible = tf
            isCorpSMSTariff.Visible = tf
            tariffDeviceSegment.Visible = tf
            tariffSegment.Visible = tf
            GPOSegment.Visible = tf
            isFPMTariff.Visible = tf
        ElseIf group.Equals("kfct") Then
            SetVisibilityOfGroup("all", False)
            tariffLineType.Visible = tf
            tariffSegment.Visible = tf
            GPOSegment.Visible = tf
        ElseIf group.Equals("kdata") Then
            SetVisibilityOfGroup("all", False)
            isM2MTariff.Visible = tf
            isJetTariff.Visible = tf
            tariffLineType.Visible = tf
            tariffSegment.Visible = tf
            GPOSegment.Visible = tf
            isPOSTariff.Visible = tf
        End If

    End Sub

    Protected Sub CommentRow(ByVal rowId As Integer, ByVal comment As String)
        If rowId = 0 Then 'SameAs
            If ddlSameAsTariff.SelectedValue.Equals("Yes") Then
                sameAsLabel01.Text = comment
                sameAsBox01_c.Visible = True
            End If
        End If
        If rowId = 1 Then 'Date
        End If
        If rowId = 2 Then 'TariffType
            If ddlTariffType.SelectedIndex <> 0 Then
                sameAsLabel02.Text = comment
                sameAsBox02_c.Visible = True
            End If
        End If
        If rowId = 3 Then 'TariffLineType
            If tariffLineType.Visible Then
                If ddlTariffLineType.SelectedIndex <> 0 Then
                    sameAsLabel03.Text = comment
                    sameAsBox03_c.Visible = True
                End If
            End If
        End If
        If rowId = 4 Then 'TariffDeviceSegment
            If tariffDeviceSegment.Visible Then
                If ddlTariffDeviceSegment.SelectedIndex <> 0 Then
                    sameAsLabel04.Text = comment
                    sameAsBox04_c.Visible = True
                End If
            End If
        End If
        If rowId = 5 Then 'TariffSegment
            If tariffSegment.Visible Then
                If ddlTariffSegment.SelectedIndex <> 0 Then
                    sameAsLabel05.Text = comment
                    sameAsBox05_c.Visible = True
                End If
            End If
        End If
        If rowId = 6 Then 'GPO
            If GPOSegment.Visible Then
                'If ddlGPOSegment.SelectedIndex <> 0 Then
                    sameAsLabel06.Text = comment
                    sameAsBox06_c.Visible = True
                'End If
            End If
        End If
        If rowId = 8 Then 'JET
            If isJetTariff.Visible Then
                If ddlIsJetTariff.SelectedIndex <> 0 Then
                    sameAsLabel08.Text = comment
                    sameAsBox08_c.Visible = True
                End If
            End If
        End If
        If rowId = 9 Then 'M2M
            If isM2MTariff.Visible Then
                If ddlIsM2MTariff.SelectedIndex <> 0 Then
                    sameAsLabel09.Text = comment
                    sameAsBox09_c.Visible = True
                End If
            End If
        End If
        If rowId = 10 Then 'CorpSMS
            If isCorpSMSTariff.Visible Then
                If ddlIsCorpSMSTariff.SelectedIndex <> 0 Then
                    sameAsLabel10.Text = comment
                    sameAsBox10_c.Visible = True
                End If
            End If
        End If
        If rowId = 11 Then 'FPM
            If isFPMTariff.Visible Then
                If ddlIsFPMTariff.SelectedIndex <> 0 Then
                    sameAsLabel11.Text = comment
                    sameAsBox11_c.Visible = True
                End If
            End If
        End If
        If rowId = 12 Then 'POS
            If isPOSTariff.Visible Then
                If ddlIsPOSTariff.SelectedIndex <> 0 Then
                    sameAsLabel12.Text = comment
                    sameAsBox12_c.Visible = True
                End If
            End If
        End If

    End Sub

    Protected Sub ClearBetween(ByVal a As Integer, ByVal z As Integer)
        Dim i As Integer
        For i = a To z
            ClearRow(i)
        Next i
    End Sub

    Protected Sub CommentBetween(ByVal a As Integer, ByVal z As Integer, ByVal comment As String)
        Dim i As Integer
        For i = a To z
            CommentRow(i, comment)
        Next i
    End Sub


    Protected Sub ddlSameAsTariff_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlSameAsTariff.SelectedIndexChanged
        If ddlSameAsTariff.SelectedValue.Equals("Yes") Then
            sameAsBox01_a.Visible = True
        Else
            sameAsBox01_a.Visible = False
            sameAsBox01_b.Visible = False
            sameAsBox01_c.Visible = False
            ClearBetween(2, 12)
            lblErr01.Text = Nothing
            txtKeywordGeneral.Text = Nothing
            tariffLineType.Visible = False
            tariffDeviceSegment.Visible = False
            tariffSegment.Visible = False
            GPOSegment.Visible = False
            isM2MTariff.Visible = False
            isJetTariff.Visible = False
            isCorpSMSTariff.Visible = False
            isFPMTariff.Visible = False
            isPOSTariff.Visible = False
            finalStatus.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeywordGeneral_Click(sender As Object, e As EventArgs) Handles btnSearchKeywordGeneral.Click
        ddlTariffListGeneral.Items.Clear()
        ddlTariffListGeneral.DataSource = DataEngine.GetGeneralTariffList(txtKeywordGeneral.Text.Trim())
        ddlTariffListGeneral.DataBind()
        If ddlTariffListGeneral.Items.Count = 0 Then
            lblErr01.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffListGeneral.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffListGeneral.SelectedIndex = 0
        txtKeywordGeneral.Text = Nothing
        sameAsLabel01.Text = Nothing
        lblErr01.Text = Nothing
        sameAsBox01_a.Visible = False
        sameAsBox01_b.Visible = True
    End Sub

    Protected Sub ddlTariffListGeneral_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffListGeneral.SelectedIndexChanged
        sameAsBox01_b.Visible = False
        sameAsLabel01.Text = ddlTariffListGeneral.SelectedItem.Text & " tarifesinden ""same as"" alınmıştır."
        sameAsBox01_c.Visible = True
        finalStatus.Visible = False

        ddlTariffType.SelectedIndex = DataEngine.GetTariffType(ddlTariffListGeneral.SelectedValue)
        ddlTariffType_SelectedIndexChanged(sender, e)

        If tariffLineType.Visible Then
            ddlTariffLineType.SelectedIndex = DataEngine.GetTariffLineType(ddlTariffListGeneral.SelectedValue)
            ddlTariffLineType_SelectedIndexChanged(sender, e)
        End If

        If tariffDeviceSegment.Visible Then
            ddlTariffDeviceSegment.SelectedIndex = DataEngine.GetTariffDeviceSegment(ddlTariffListGeneral.SelectedValue)
            ddlTariffDeviceSegment_SelectedIndexChanged(sender, e)
        End If

        If tariffSegment.Visible Then
            If ddlTariffType.SelectedValue.Equals("Bireysel") Then
                ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffListGeneral.SelectedValue, "B")
            Else
                If ddlTariffLineType.SelectedValue.Equals("Ses") Then
                    ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffListGeneral.SelectedValue, "A")
                Else
                    ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffListGeneral.SelectedValue, "K")
                End If
            End If
            ddlTariffSegment_SelectedIndexChanged(sender, e)
        End If

        If GPOSegment.Visible Then
            ddlGPOSegment.ClearSelection()
            ddlGPOSegment.Items.FindByValue(DataEngine.GetGPOSegment(ddlTariffListGeneral.SelectedValue)).Selected = True
        End If

        If isM2MTariff.Visible Then
            ddlIsM2MTariff.SelectedIndex = DataEngine.GetM2MTariff(ddlTariffListGeneral.SelectedValue)
            ddlIsM2MTariff_SelectedIndexChanged(sender, e)
        End If

        If isJetTariff.Visible Then
            ddlIsJetTariff.SelectedIndex = DataEngine.GetJETTariff(ddlTariffListGeneral.SelectedValue)
            ddlIsJetTariff_SelectedIndexChanged(sender, e)
        End If

        If isCorpSMSTariff.Visible Then
            ddlIsCorpSMSTariff.SelectedIndex = DataEngine.GetCorpSMS(ddlTariffListGeneral.SelectedValue)
            ddlIsCorpSMSTariff_SelectedIndexChanged(sender, e)
        End If

        If isFPMTariff.Visible Then
            ddlIsFPMTariff.SelectedIndex = 0
            ddlIsFPMTariff_SelectedIndexChanged(sender, e)
        End If

        If isPOSTariff.Visible Then
            ddlIsPOSTariff.SelectedIndex = DataEngine.GetPOSTariff(ddlTariffListGeneral.SelectedValue)
            ddlIsPOSTariff_SelectedIndexChanged(sender, e)
        End If

        CommentBetween(0, 12, ddlTariffListGeneral.SelectedValue.ToString & " - " & ddlTariffListGeneral.Items(ddlTariffListGeneral.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır.")
        'saveButton_Click(sender, e, "check")
        ' to be continued
    End Sub


    Protected Sub ddlTariffType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffType.SelectedIndexChanged
        If Not (ddlTariffType.SelectedValue.Equals("0") Or ddlTariffType.SelectedValue.Equals("SameAs")) Then
            If ddlTariffType.SelectedValue.Equals("Bireysel") Then
                ClearBetween(3, 12)

                SetVisibilityOfGroup("all", False)
                tariffLineType.Visible = True
                lblErr02.Text = Nothing

                ddlTariffLineType.Items.Insert(0, New ListItem("Seçiniz", "0"))
                ddlTariffLineType.Items.Insert(1, New ListItem("Ses Hatlı Tarife", "Ses"))
                ddlTariffLineType.Items.Insert(2, New ListItem("FCT Hatlı Tarife", "Fct"))
                ddlTariffLineType.Items.Insert(3, New ListItem("Data Hatlı Tarife", "Data"))
                ddlTariffLineType.Items.Insert(4, New ListItem("Same as ..", "SameAs"))
                ddlTariffLineType.SelectedIndex = 0

            ElseIf ddlTariffType.SelectedValue.Equals("Kurumsal") Then
                ClearBetween(3, 12)

                SetVisibilityOfGroup("all", False)
                tariffLineType.Visible = True
                lblErr02.Text = Nothing

                ddlTariffLineType.Items.Insert(0, New ListItem("Seçiniz", "0"))
                ddlTariffLineType.Items.Insert(1, New ListItem("Ses Hatlı Tarife", "Ses"))
                ddlTariffLineType.Items.Insert(2, New ListItem("FCT Hatlı Tarife", "Fct"))
                ddlTariffLineType.Items.Insert(3, New ListItem("Data Hatlı Tarife", "Data"))
                ddlTariffLineType.Items.Insert(4, New ListItem("Same as ..", "SameAs"))
                ddlTariffLineType.SelectedIndex = 0
            End If
        ElseIf ddlTariffType.SelectedValue.Equals("0") Then
            ClearBetween(2, 12)
            SetVisibilityOfGroup("all", False)
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub ddlTariffList02_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList02.SelectedIndexChanged

    End Sub


    Protected Sub ddlTariffLineType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffLineType.SelectedIndexChanged
        If Not (ddlTariffLineType.SelectedValue.Equals("0") Or ddlTariffLineType.SelectedValue.Equals("SameAs")) Then
            ClearBetween(4, 12)
            If ddlTariffType.SelectedValue.Equals("Bireysel") Then
                If ddlTariffLineType.SelectedValue.Equals("Ses") Then
                    SetVisibilityOfGroup("bses", True)
                    lblErr03.Text = Nothing

                    ddlTariffDeviceSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffDeviceSegment.Items.Insert(1, New ListItem("Grup 1", "1"))
                    ddlTariffDeviceSegment.Items.Insert(2, New ListItem("Grup 2", "2"))
                    ddlTariffDeviceSegment.Items.Insert(3, New ListItem("Grup 3", "3"))
                    ddlTariffDeviceSegment.Items.Insert(4, New ListItem("Grup 4", "4"))
                    ddlTariffDeviceSegment.Items.Insert(5, New ListItem("Grup 5", "5"))
                    ddlTariffDeviceSegment.Items.Insert(6, New ListItem("Grup 6", "6"))
                    ddlTariffDeviceSegment.Items.Insert(7, New ListItem("Same as ..", "SameAs"))
                    ddlTariffDeviceSegment.SelectedIndex = 0
                    ddlTariffSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffSegment.Items.Insert(1, New ListItem("Mass", "Mass"))
                    ddlTariffSegment.Items.Insert(2, New ListItem("Institutional", "Inst"))
                    ddlTariffSegment.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlTariffSegment.SelectedIndex = 0
                    ddlGPOSegment.DataSource = DataEngine.GetGPOList()
                    ddlGPOSegment.DataBind()
                    ddlGPOSegment.Items.Insert(0, New ListItem("N/A", "NA"))
                    ddlGPOSegment.Items.Insert(ddlGPOSegment.Items.Count, New ListItem("Same as ..", "SameAs"))
                    ddlGPOSegment.SelectedIndex = 0
                ElseIf ddlTariffLineType.SelectedValue.Equals("Fct") Then
                    SetVisibilityOfGroup("bfct", True)
                    lblErr03.Text = Nothing

                    ddlTariffSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffSegment.Items.Insert(1, New ListItem("Mass", "Mass"))
                    ddlTariffSegment.Items.Insert(2, New ListItem("Institutional", "Inst"))
                    ddlTariffSegment.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlTariffSegment.SelectedIndex = 0
                    ddlGPOSegment.DataSource = DataEngine.GetGPOList()
                    ddlGPOSegment.DataBind()
                    ddlGPOSegment.Items.Insert(0, New ListItem("N/A", "NA"))
                    ddlGPOSegment.Items.Insert(ddlGPOSegment.Items.Count, New ListItem("Same as ..", "SameAs"))
                    ddlGPOSegment.SelectedIndex = 0
                ElseIf ddlTariffLineType.SelectedValue.Equals("Data") Then
                    SetVisibilityOfGroup("bdata", True)
                    lblErr03.Text = Nothing

                    ddlIsJetTariff.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlIsJetTariff.Items.Insert(1, New ListItem("Evet", "Yes"))
                    ddlIsJetTariff.Items.Insert(2, New ListItem("Hayır", "No"))
                    ddlIsJetTariff.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlIsJetTariff.SelectedIndex = 2
                    ddlTariffSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffSegment.Items.Insert(1, New ListItem("Mass", "Mass"))
                    ddlTariffSegment.Items.Insert(2, New ListItem("Institutional", "Inst"))
                    ddlTariffSegment.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlTariffSegment.SelectedIndex = 0
                    ddlGPOSegment.DataSource = DataEngine.GetGPOList()
                    ddlGPOSegment.DataBind()
                    ddlGPOSegment.Items.Insert(0, New ListItem("N/A", "NA"))
                    ddlGPOSegment.Items.Insert(ddlGPOSegment.Items.Count, New ListItem("Same as ..", "SameAs"))
                    ddlGPOSegment.SelectedIndex = 0
                    ddlIsM2MTariff.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlIsM2MTariff.Items.Insert(1, New ListItem("Evet", "Yes"))
                    ddlIsM2MTariff.Items.Insert(2, New ListItem("Hayır", "No"))
                    ddlIsM2MTariff.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlIsM2MTariff.SelectedIndex = 2
                End If
            ElseIf ddlTariffType.SelectedValue.Equals("Kurumsal") Then
                If ddlTariffLineType.SelectedValue.Equals("Ses") Then
                    SetVisibilityOfGroup("kses", True)
                    lblErr03.Text = Nothing

                    ddlIsCorpSMSTariff.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlIsCorpSMSTariff.Items.Insert(1, New ListItem("Evet", "Yes"))
                    ddlIsCorpSMSTariff.Items.Insert(2, New ListItem("Hayır", "No"))
                    ddlIsCorpSMSTariff.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlIsCorpSMSTariff.SelectedIndex = 2
                    ddlTariffDeviceSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffDeviceSegment.Items.Insert(1, New ListItem("Grup 1", "1"))
                    ddlTariffDeviceSegment.Items.Insert(2, New ListItem("Grup 2", "2"))
                    ddlTariffDeviceSegment.Items.Insert(3, New ListItem("Grup 3", "3"))
                    ddlTariffDeviceSegment.Items.Insert(4, New ListItem("Grup 4", "4"))
                    ddlTariffDeviceSegment.Items.Insert(5, New ListItem("Grup 5", "5"))
                    ddlTariffDeviceSegment.Items.Insert(6, New ListItem("Grup 6", "6"))
                    ddlTariffDeviceSegment.Items.Insert(7, New ListItem("Same as ..", "SameAs"))
                    ddlTariffDeviceSegment.SelectedIndex = 0
                    ddlTariffSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffSegment.Items.Insert(1, New ListItem("Mass", "Mass"))
                    ddlTariffSegment.Items.Insert(2, New ListItem("Institutional", "Inst"))
                    ddlTariffSegment.Items.Insert(3, New ListItem("SME", "Sme"))
                    ddlTariffSegment.Items.Insert(4, New ListItem("Corp", "Corp"))
                    ddlTariffSegment.Items.Insert(5, New ListItem("Same as ..", "SameAs"))
                    ddlTariffSegment.SelectedIndex = 0
                    ddlGPOSegment.DataSource = DataEngine.GetGPOList()
                    ddlGPOSegment.DataBind()
                    ddlGPOSegment.Items.Insert(0, New ListItem("N/A", "NA"))
                    ddlGPOSegment.Items.Insert(ddlGPOSegment.Items.Count, New ListItem("Same as ..", "SameAs"))
                    ddlGPOSegment.SelectedIndex = 0
                    ddlIsFPMTariff.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlIsFPMTariff.Items.Insert(1, New ListItem("Evet", "Yes"))
                    ddlIsFPMTariff.Items.Insert(2, New ListItem("Hayır", "No"))
                    ddlIsFPMTariff.SelectedIndex = 2
                ElseIf ddlTariffLineType.SelectedValue.Equals("Fct") Then
                    SetVisibilityOfGroup("kfct", True)
                    lblErr03.Text = Nothing

                    ddlTariffSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffSegment.Items.Insert(1, New ListItem("SME", "Sme"))
                    ddlTariffSegment.Items.Insert(2, New ListItem("Corp", "Corp"))
                    ddlTariffSegment.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlTariffSegment.SelectedIndex = 0
                    ddlGPOSegment.DataSource = DataEngine.GetGPOList()
                    ddlGPOSegment.DataBind()
                    ddlGPOSegment.Items.Insert(0, New ListItem("N/A", "NA"))
                    ddlGPOSegment.Items.Insert(ddlGPOSegment.Items.Count, New ListItem("Same as ..", "SameAs"))
                    ddlGPOSegment.SelectedIndex = 0
                ElseIf ddlTariffLineType.SelectedValue.Equals("Data") Then
                    SetVisibilityOfGroup("kdata", True)
                    lblErr03.Text = Nothing

                    ddlIsJetTariff.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlIsJetTariff.Items.Insert(1, New ListItem("Evet", "Yes"))
                    ddlIsJetTariff.Items.Insert(2, New ListItem("Hayır", "No"))
                    ddlIsJetTariff.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlIsJetTariff.SelectedIndex = 2
                    ddlIsPOSTariff.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlIsPOSTariff.Items.Insert(1, New ListItem("Evet", "Yes"))
                    ddlIsPOSTariff.Items.Insert(2, New ListItem("Hayır", "No"))
                    ddlIsPOSTariff.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlIsPOSTariff.SelectedIndex = 2
                    ddlTariffSegment.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlTariffSegment.Items.Insert(1, New ListItem("SME", "Sme"))
                    ddlTariffSegment.Items.Insert(2, New ListItem("Corp", "Corp"))
                    ddlTariffSegment.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlTariffSegment.SelectedIndex = 0
                    ddlGPOSegment.DataSource = DataEngine.GetGPOList()
                    ddlGPOSegment.DataBind()
                    ddlGPOSegment.Items.Insert(0, New ListItem("N/A", "NA"))
                    ddlGPOSegment.Items.Insert(ddlGPOSegment.Items.Count, New ListItem("Same as ..", "SameAs"))
                    ddlGPOSegment.SelectedIndex = 0
                    ddlIsM2MTariff.Items.Insert(0, New ListItem("Seçiniz", "0"))
                    ddlIsM2MTariff.Items.Insert(1, New ListItem("Evet", "Yes"))
                    ddlIsM2MTariff.Items.Insert(2, New ListItem("Hayır", "No"))
                    ddlIsM2MTariff.Items.Insert(3, New ListItem("Same as ..", "SameAs"))
                    ddlIsM2MTariff.SelectedIndex = 2
                End If
            End If
        ElseIf ddlTariffLineType.SelectedValue.Equals("0") Then
            ClearBetween(3, 12)

            SetVisibilityOfGroup("all", False)
            tariffLineType.Visible = True

            ddlTariffLineType.Items.Insert(0, New ListItem("Seçiniz", "0"))
            ddlTariffLineType.Items.Insert(1, New ListItem("Ses Hatlı Tarife", "Ses"))
            ddlTariffLineType.Items.Insert(2, New ListItem("FCT Hatlı Tarife", "Fct"))
            ddlTariffLineType.Items.Insert(3, New ListItem("Data Hatlı Tarife", "Data"))
            ddlTariffLineType.Items.Insert(4, New ListItem("Same as ..", "SameAs"))
            ddlTariffLineType.SelectedIndex = 0
        ElseIf ddlTariffLineType.SelectedValue.Equals("SameAs") Then
            ClearBetween(3, 12)

            SetVisibilityOfGroup("all", False)
            tariffLineType.Visible = True

            ddlTariffLineType.Items.Insert(0, New ListItem("Seçiniz", "0"))
            ddlTariffLineType.Items.Insert(1, New ListItem("Ses Hatlı Tarife", "Ses"))
            ddlTariffLineType.Items.Insert(2, New ListItem("FCT Hatlı Tarife", "Fct"))
            ddlTariffLineType.Items.Insert(3, New ListItem("Data Hatlı Tarife", "Data"))
            ddlTariffLineType.Items.Insert(4, New ListItem("Same as ..", "SameAs"))
            ddlTariffLineType.SelectedIndex = 4
            sameAsBox03_a.Visible = True
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword03_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword03.Click
        ddlTariffList03.Items.Clear()
        ddlTariffList03.DataSource = DataEngine.GetGeneralTariffList(txtKeyword03.Text.Trim())
        ddlTariffList03.DataBind()
        If ddlTariffList03.Items.Count = 0 Then
            lblErr03.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList03.Items.Insert(0, New ListItem("Seçiniz", "0"))
        'ddlTariffList03.Items.Insert(0, "Seçiniz")
        ddlTariffList03.SelectedIndex = 0
        txtKeyword03.Text = Nothing
        sameAsLabel03.Text = Nothing
        lblErr03.Text = Nothing
        sameAsBox03_a.Visible = False
        sameAsBox03_b.Visible = True
    End Sub

    Protected Sub ddlTariffList03_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList03.SelectedIndexChanged
        sameAsBox03_b.Visible = False
        sameAsLabel03.Text = ddlTariffList03.Items(ddlTariffList03.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
        sameAsBox03_c.Visible = True
        ddlTariffLineType.SelectedIndex = DataEngine.GetTariffLineType(ddlTariffList03.SelectedValue)
        ddlTariffLineType_SelectedIndexChanged(sender, e)

        If ddlTariffLineType.SelectedIndex <> 0 Then
            If tariffDeviceSegment.Visible Then
                ddlTariffDeviceSegment.SelectedIndex = DataEngine.GetTariffDeviceSegment(ddlTariffList04.SelectedValue)
            End If

            If tariffSegment.Visible Then
                If ddlTariffType.SelectedValue.Equals("Bireysel") Then
                    ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffList03.SelectedValue, "B")
                Else
                    If ddlTariffLineType.SelectedValue.Equals("Ses") Then
                        ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffList03.SelectedValue, "A")
                    Else
                        ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffList03.SelectedValue, "K")
                    End If
                End If
            End If

            If GPOSegment.Visible Then
                ddlGPOSegment.SelectedItem.Value = DataEngine.GetGPOSegment(ddlTariffList03.SelectedValue)
            End If

            If isM2MTariff.Visible Then
                ddlIsM2MTariff.SelectedIndex = DataEngine.GetM2MTariff(ddlTariffList03.SelectedValue)
            End If

            If isJetTariff.Visible Then
                ddlIsJetTariff.SelectedIndex = DataEngine.GetJETTariff(ddlTariffList03.SelectedValue)
            End If

            If isCorpSMSTariff.Visible Then
                ddlIsCorpSMSTariff.SelectedIndex = DataEngine.GetCorpSMS(ddlTariffList03.SelectedValue)
            End If

            If isFPMTariff.Visible Then
                ddlIsFPMTariff.SelectedIndex = 0
            End If

            If isPOSTariff.Visible Then
                ddlIsPOSTariff.SelectedIndex = DataEngine.GetPOSTariff(ddlTariffList03.SelectedValue)
            End If

            CommentBetween(3, 12, ddlTariffList03.SelectedValue.ToString & " - " & ddlTariffList03.SelectedItem.Text & " tarifesinden ""same as"" alınmıştır.")
            'saveButton_Click(sender, e, "check")
        Else
            lblErr03.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox03_b.Visible = False
            sameAsBox03_c.Visible = False
        End If
    End Sub


    Protected Sub ddlTariffDeviceSegment_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffDeviceSegment.SelectedIndexChanged
        sameAsBox04_a.Visible = False
        sameAsBox04_b.Visible = False
        sameAsBox04_c.Visible = False
        lblErr04.Text = Nothing

        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword04_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword04.Click
        ddlTariffList04.Items.Clear()
        ddlTariffList04.DataSource = DataEngine.GetGeneralTariffList(txtKeyword04.Text.Trim())
        ddlTariffList04.DataBind()
        If ddlTariffList04.Items.Count = 0 Then
            lblErr04.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList04.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList04.SelectedIndex = 0
        txtKeyword04.Text = Nothing
        sameAsLabel04.Text = Nothing
        lblErr04.Text = Nothing
        sameAsBox04_a.Visible = False
        sameAsBox04_b.Visible = True
    End Sub

    Protected Sub ddlTariffList04_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList04.SelectedIndexChanged
        ddlTariffDeviceSegment.SelectedIndex = DataEngine.GetTariffDeviceSegment(ddlTariffList04.SelectedValue)

        If ddlTariffDeviceSegment.SelectedIndex <> 0 Then
            sameAsBox04_b.Visible = False
            sameAsLabel04.Text = ddlTariffList04.Items(ddlTariffList04.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
            sameAsBox04_c.Visible = True
        Else
            lblErr04.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox04_b.Visible = False
            sameAsBox04_c.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub


    Protected Sub ddlTariffSegment_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffSegment.SelectedIndexChanged
        sameAsBox05_a.Visible = False
        sameAsBox05_b.Visible = False
        sameAsBox05_c.Visible = False
        lblErr05.Text = Nothing
        If Not (ddlTariffSegment.SelectedValue.Equals("0") Or ddlTariffSegment.SelectedValue.Equals("SameAs")) Then
        ElseIf ddlTariffSegment.SelectedValue.Equals("0") Then
        ElseIf ddlTariffSegment.SelectedValue.Equals("SameAs") Then
            sameAsBox05_a.Visible = True
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword05_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword05.Click
        ddlTariffList05.Items.Clear()
        ddlTariffList05.DataSource = DataEngine.GetGeneralTariffList(txtKeyword05.Text.Trim())
        ddlTariffList05.DataBind()
        If ddlTariffList05.Items.Count = 0 Then
            lblErr05.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList05.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList05.SelectedIndex = 0
        txtKeyword05.Text = Nothing
        sameAsLabel05.Text = Nothing
        lblErr05.Text = Nothing
        sameAsBox05_a.Visible = False
        sameAsBox05_b.Visible = True
    End Sub

    Protected Sub ddlTariffList05_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList05.SelectedIndexChanged
        If ddlTariffType.SelectedValue.Equals("Bireysel") Then
            ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffList05.SelectedValue, "B")
        Else
            If ddlTariffLineType.SelectedValue.Equals("Ses") Then
                ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffList05.SelectedValue, "A")
            Else
                ddlTariffSegment.SelectedIndex = DataEngine.GetTariffSegment(ddlTariffList05.SelectedValue, "K")
            End If
        End If
        If ddlTariffSegment.SelectedIndex <> 0 Then
            sameAsBox05_b.Visible = False
            sameAsLabel05.Text = ddlTariffList05.Items(ddlTariffList05.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
            sameAsBox05_c.Visible = True
        Else
            lblErr05.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox05_b.Visible = False
            sameAsBox05_c.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub


    Protected Sub ddlGPOSegment_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlGPOSegment.SelectedIndexChanged
        sameAsBox06_a.Visible = False
        sameAsBox06_b.Visible = False
        sameAsBox06_c.Visible = False
        lblErr06.Text = Nothing
        If Not (ddlGPOSegment.SelectedValue.Equals("NA") Or ddlGPOSegment.SelectedValue.Equals("SameAs")) Then
        ElseIf ddlGPOSegment.SelectedValue.Equals("NA") Then
        ElseIf ddlGPOSegment.SelectedValue.Equals("SameAs") Then
            sameAsBox06_a.Visible = True
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword06_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword06.Click
        ddlTariffList06.Items.Clear()
        ddlTariffList06.DataSource = DataEngine.GetGeneralTariffList(txtKeyword06.Text.Trim())
        ddlTariffList06.DataBind()
        If ddlTariffList06.Items.Count = 0 Then
            lblErr06.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList06.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList06.SelectedIndex = 0
        txtKeyword06.Text = Nothing
        sameAsLabel06.Text = Nothing
        lblErr06.Text = Nothing
        sameAsBox06_a.Visible = False
        sameAsBox06_b.Visible = True
    End Sub

    Protected Sub ddlTariffList06_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList06.SelectedIndexChanged
        ddlGPOSegment.ClearSelection()
        ddlGPOSegment.Items.FindByValue(DataEngine.GetGPOSegment(ddlTariffList06.SelectedValue)).Selected = True

        sameAsBox06_b.Visible = False
        sameAsLabel06.Text = ddlTariffList06.Items(ddlTariffList06.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
        sameAsBox06_c.Visible = True
    End Sub


    Protected Sub ddlIsJetTariff_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlIsJetTariff.SelectedIndexChanged
        sameAsBox08_a.Visible = False
        sameAsBox08_b.Visible = False
        sameAsBox08_c.Visible = False
        lblErr08.Text = Nothing
        If Not (ddlIsJetTariff.SelectedValue.Equals("0") Or ddlIsJetTariff.SelectedValue.Equals("SameAs")) Then
        ElseIf ddlIsJetTariff.SelectedValue.Equals("0") Then
        ElseIf ddlIsJetTariff.SelectedValue.Equals("SameAs") Then
            sameAsBox08_a.Visible = True
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword08_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword08.Click
        ddlTariffList08.Items.Clear()
        ddlTariffList08.DataSource = DataEngine.GetGeneralTariffList(txtKeyword08.Text.Trim())
        ddlTariffList08.DataBind()
        If ddlTariffList08.Items.Count = 0 Then
            lblErr08.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList08.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList08.SelectedIndex = 0
        txtKeyword08.Text = Nothing
        sameAsLabel08.Text = Nothing
        lblErr08.Text = Nothing
        sameAsBox08_a.Visible = False
        sameAsBox08_b.Visible = True
    End Sub

    Protected Sub ddlTariffList08_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList08.SelectedIndexChanged
        'ddlIsJetTariff.SelectedIndex = 0
        ddlIsJetTariff.SelectedIndex = DataEngine.GetJETTariff(ddlTariffList08.SelectedValue)
        If ddlIsJetTariff.SelectedIndex <> 0 Then
            sameAsBox08_b.Visible = False
            sameAsLabel08.Text = ddlTariffList08.Items(ddlTariffList08.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
            sameAsBox08_c.Visible = True
        Else
            lblErr08.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox08_b.Visible = False
            sameAsBox08_c.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub


    Protected Sub ddlIsM2MTariff_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlIsM2MTariff.SelectedIndexChanged
        sameAsBox09_a.Visible = False
        sameAsBox09_b.Visible = False
        sameAsBox09_c.Visible = False
        lblErr09.Text = Nothing
        If Not (ddlIsM2MTariff.SelectedValue.Equals("0") Or ddlIsM2MTariff.SelectedValue.Equals("SameAs")) Then
        ElseIf ddlIsM2MTariff.SelectedValue.Equals("0") Then
        ElseIf ddlIsM2MTariff.SelectedValue.Equals("SameAs") Then
            sameAsBox09_a.Visible = True
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword09_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword09.Click
        ddlTariffList09.Items.Clear()
        ddlTariffList09.DataSource = DataEngine.GetGeneralTariffList(txtKeyword09.Text.Trim())
        ddlTariffList09.DataBind()
        If ddlTariffList09.Items.Count = 0 Then
            lblErr09.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList09.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList09.SelectedIndex = 0
        txtKeyword09.Text = Nothing
        sameAsLabel09.Text = Nothing
        lblErr09.Text = Nothing
        sameAsBox09_a.Visible = False
        sameAsBox09_b.Visible = True
    End Sub

    Protected Sub ddlTariffList09_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList09.SelectedIndexChanged
        ddlIsM2MTariff.SelectedIndex = DataEngine.GetM2MTariff(ddlTariffList09.SelectedValue)
        If ddlIsM2MTariff.SelectedIndex <> 0 Then
            sameAsBox09_b.Visible = False
            sameAsLabel09.Text = ddlTariffList09.Items(ddlTariffList09.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
            sameAsBox09_c.Visible = True
        Else
            lblErr09.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox09_b.Visible = False
            sameAsBox09_c.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub


    Protected Sub ddlIsCorpSMSTariff_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlIsCorpSMSTariff.SelectedIndexChanged
        sameAsBox10_a.Visible = False
        sameAsBox10_b.Visible = False
        sameAsBox10_c.Visible = False
        lblErr10.Text = Nothing
        If Not (ddlIsCorpSMSTariff.SelectedValue.Equals("0") Or ddlIsCorpSMSTariff.SelectedValue.Equals("SameAs")) Then
        ElseIf ddlIsCorpSMSTariff.SelectedValue.Equals("0") Then
        ElseIf ddlIsCorpSMSTariff.SelectedValue.Equals("SameAs") Then
            sameAsBox10_a.Visible = True
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword10_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword10.Click
        ddlTariffList10.Items.Clear()
        ddlTariffList10.DataSource = DataEngine.GetGeneralTariffList(txtKeyword10.Text.Trim())
        ddlTariffList10.DataBind()
        If ddlTariffList10.Items.Count = 0 Then
            lblErr10.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList10.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList10.SelectedIndex = 0
        txtKeyword10.Text = Nothing
        sameAsLabel10.Text = Nothing
        lblErr10.Text = Nothing
        sameAsBox10_a.Visible = False
        sameAsBox10_b.Visible = True
    End Sub

    Protected Sub ddlTariffList10_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList10.SelectedIndexChanged
        ddlIsCorpSMSTariff.SelectedIndex = DataEngine.GetCorpSMS(ddlTariffList10.SelectedValue)

        If ddlIsCorpSMSTariff.SelectedIndex <> 0 Then
            sameAsBox10_b.Visible = False
            sameAsLabel10.Text = ddlTariffList10.Items(ddlTariffList10.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
            sameAsBox10_c.Visible = True
        Else
            lblErr10.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox10_b.Visible = False
            sameAsBox10_c.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub


    Protected Sub ddlIsFPMTariff_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlIsFPMTariff.SelectedIndexChanged
        sameAsBox11_a.Visible = False
        sameAsBox11_b.Visible = False
        sameAsBox11_c.Visible = False
        lblErr11.Text = Nothing
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword11_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword11.Click
        ddlTariffList11.Items.Clear()
        ddlTariffList11.DataSource = DataEngine.GetGeneralTariffList(txtKeyword11.Text.Trim())
        ddlTariffList11.DataBind()
        If ddlTariffList11.Items.Count = 0 Then
            lblErr11.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList11.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList11.SelectedIndex = 0
        txtKeyword11.Text = Nothing
        sameAsLabel11.Text = Nothing
        lblErr11.Text = Nothing
        sameAsBox11_a.Visible = False
        sameAsBox11_b.Visible = True
    End Sub

    Protected Sub ddlTariffList11_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList11.SelectedIndexChanged
        ddlIsFPMTariff.SelectedIndex = 0

        If ddlIsFPMTariff.SelectedIndex <> 0 Then
            sameAsBox11_b.Visible = False
            sameAsLabel11.Text = ddlTariffList11.Items(ddlTariffList11.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
            sameAsBox11_c.Visible = True
        Else
            lblErr11.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox11_b.Visible = False
            sameAsBox11_c.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub


    Protected Sub ddlIsPOSTariff_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlIsPOSTariff.SelectedIndexChanged
        sameAsBox12_a.Visible = False
        sameAsBox12_b.Visible = False
        sameAsBox12_c.Visible = False
        lblErr12.Text = Nothing
        If Not (ddlIsPOSTariff.SelectedValue.Equals("0") Or ddlIsPOSTariff.SelectedValue.Equals("SameAs")) Then
        ElseIf ddlIsPOSTariff.SelectedValue.Equals("0") Then
        ElseIf ddlIsPOSTariff.SelectedValue.Equals("SameAs") Then
            sameAsBox12_a.Visible = True
        End If
        'saveButton_Click(sender, e, "check")
    End Sub

    Protected Sub btnSearchKeyword12_Click(sender As Object, e As EventArgs) Handles btnSearchKeyword12.Click
        ddlTariffList12.Items.Clear()
        ddlTariffList12.DataSource = DataEngine.GetGeneralTariffList(txtKeyword12.Text.Trim())
        ddlTariffList12.DataBind()
        If ddlTariffList12.Items.Count = 0 Then
            lblErr12.Text = "Girdiğiniz değerle eşleşen bir tarife bulunamamıştır. Lütfen yeni bir değer giriniz."
            Return
        End If

        ddlTariffList12.Items.Insert(0, New ListItem("Seçiniz", "0"))
        ddlTariffList12.SelectedIndex = 0
        txtKeyword12.Text = Nothing
        sameAsLabel12.Text = Nothing
        lblErr12.Text = Nothing
        sameAsBox12_a.Visible = False
        sameAsBox12_b.Visible = True
    End Sub

    Protected Sub ddlTariffList12_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTariffList12.SelectedIndexChanged
        ddlIsPOSTariff.SelectedIndex = DataEngine.GetPOSTariff(ddlTariffList12.SelectedValue)

        If ddlIsPOSTariff.SelectedIndex <> 0 Then
            sameAsBox12_b.Visible = False
            sameAsLabel12.Text = ddlTariffList12.Items(ddlTariffList12.SelectedIndex).ToString & " tarifesinden ""same as"" alınmıştır."
            sameAsBox12_c.Visible = True
        Else
            lblErr12.Text = "Seçtiğiniz tarifeden bu alan için uygun bir data elde edilememiştir."
            sameAsBox12_b.Visible = False
            sameAsBox12_c.Visible = False
        End If
        'saveButton_Click(sender, e, "check")
    End Sub


    Protected Sub saveButton_Click(sender As Object, e As EventArgs, Optional ByVal purpose As String = "save") Handles saveButton.Click
        Dim checkAllfieldsOk As Boolean = True
        finalStatus.Visible = True
        If ddlTariffType.SelectedValue.Equals("0") Then
            checkAllfieldsOk = False
            lblErr02.Text = "Tarife tipi boş bırakılamaz."
            lblErr02.Visible = True
        End If

        If tariffLineType.Visible Then
            If ddlTariffLineType.SelectedValue.Equals("0") Or ddlTariffLineType.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr03.Text = "Tarife hat tipi boş bırakılamaz."
                lblErr03.Visible = True
            End If
        End If

        If tariffDeviceSegment.Visible Then
            If ddlTariffDeviceSegment.SelectedValue.Equals("0") Or ddlTariffDeviceSegment.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr04.Text = "Tarife cihaz segmenti boş bırakılamaz."
                lblErr04.Visible = True
            End If
        End If

        If tariffSegment.Visible Then
            If ddlTariffSegment.SelectedValue.Equals("0") Or ddlTariffSegment.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr05.Text = "Tarife segmenti boş bırakılamaz."
                lblErr05.Visible = True
            End If
        End If

        If GPOSegment.Visible Then
            If ddlGPOSegment.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr06.Text = "GPO segmenti boş bırakılamaz."
                lblErr06.Visible = True
            End If
        End If

        If isJetTariff.Visible Then
            If ddlIsJetTariff.SelectedValue.Equals("0") Or ddlIsJetTariff.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr08.Text = "Jet tarifesi alanı boş bırakılamaz."
                lblErr08.Visible = True
            End If
        End If

        If isM2MTariff.Visible Then
            If ddlIsM2MTariff.SelectedValue.Equals("0") Or ddlIsM2MTariff.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr09.Text = "M2M tarifesi alanı boş bırakılamaz."
                lblErr09.Visible = True
            End If
        End If

        If isCorpSMSTariff.Visible Then
            If ddlIsCorpSMSTariff.SelectedValue.Equals("0") Or ddlIsCorpSMSTariff.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr10.Text = "Kurumsal SMS tarifesi alanı boş bırakılamaz."
                lblErr10.Visible = True
            End If
        End If

        If isFPMTariff.Visible Then
            If ddlIsFPMTariff.SelectedValue.Equals("0") Then
                checkAllfieldsOk = False
                lblErr11.Text = "FPM tarifesi alanı boş bırakılamaz."
                lblErr11.Visible = True
            End If
        End If

        If isPOSTariff.Visible Then
            If ddlIsPOSTariff.SelectedValue.Equals("0") Or ddlIsPOSTariff.SelectedValue.Equals("SameAs") Then
                checkAllfieldsOk = False
                lblErr12.Text = "POS tarifesi alanı boş bırakılamaz."
                lblErr12.Visible = True
            End If
        End If
        If purpose.Equals("save") Then
            If checkAllfieldsOk Then
                finalStatus.Text = "İşlem başarılı."
            Else
                finalStatus.Text = "Zorunlu alanları doldurmadan kaydedemezsiniz. Yine de çalışmalarınızı taslak olarak kaydedebilirsiniz."
            End If
        ElseIf purpose.Equals("check") Then
            finalStatus.Text = Nothing
        End If


    End Sub

    Protected Sub updateButton_Click(sender As Object, e As EventArgs) Handles updateButton.Click
        finalStatus.Text = "Daha sonra devam edebilmeniz için çalışma taslak olarak kaydedildi."
        finalStatus.Visible = True
    End Sub


    Protected Sub saveButton_Click(sender As Object, e As EventArgs)
        
    End Sub
End Class